# 基数排序
from utils.array_utils import check_is_sorted


def sort(l):
    for j in range(len(str(max(l)))):
        l2 = [[] for i in range(10)]
        for i in range(len(l)):
            num = l[i] // 10 ** j % 10
            l2[num].append(l[i])
        l.clear()
        for i in l2:
            for k in i:
                l.append(k)
        # print(l)
    print(l)


def sort02(l):
    mi = min(l)
    if mi < 0:
        for i in range(len(l)):
            l[i] -= mi
    # print(l)
    # print(i)
    for j in range(len(str(abs(max(l))))):
        l2 = [[] for i in range(10)]
        for i in range(len(l)):
            num = l[i] // 10 ** j % 10
            l2[num].append(l[i])
        l.clear()
        for i in l2:
            for k in i:
                l.append(k)
        # print(l)
    # print(l)
    if mi < 0:
        for i in range(len(l)):
            l[i] += mi


def twowei():
    ll = [[201, 102, 1, 201, 102, 1, 201, 102, 1], [11, 11, 11], [], [], [], [53, 53, 53], [], [], [], []]
    for i in ll:
        # print(i)
        for j in i:
            print(j)


if __name__ == '__main__':
    ll = [-201, -530, -102, -110, -100]
    sort02(ll)
    a = input('please input:')
    print(type(a))
    print(ll)
    print(check_is_sorted(sort02))
    # twowei()
